<?php
require_once '../sub/init.php';
$currfields = 'sex,grade';
require_once ZEAI.'m/my_chk_u.php';
require_once ZEAI.'cache/config_vip.php';
$urole     = json_decode($_ZEAI['urole']);
$photo_num = json_decode($_VIP['photo_num']);
$switch    = json_decode($_ZEAI['switch'],true);
$t = (ifint($t,'1-2','1'))?$t:1;
$cook_grade = intval($row['grade']);
$cook_sex   = intval($row['sex']);
require_once ZEAI.'cache/config_up.php';
require_once ZEAI.'sub/zeai_up_func.php';
require_once ZEAI.'sub/ZeaiUP.php';
require_once ZEAI.'cache/udata.php';
switch ($submitok) {
	case 'ajax_photo_del':
		if (ifint($id)){
			$row = $db->ROW(__TBL_PHOTO__,"path_s","uid=".$cook_uid." AND id=".$id,"num");
			if ($row){
				$path_s = $row[0];$path_b = smb($path_s,'b');
				@up_send_userdel($path_s.'|'.$path_b);
				$db->query("DELETE FROM ".__TBL_PHOTO__." WHERE id=".$id);
				json_exit(array('flag'=>1));
			}
		}
		json_exit(array('flag'=>0));
	break;
}
$rt=$db->query("SELECT id,path_s,flag FROM ".__TBL_PHOTO__." WHERE uid=".$cook_uid." ORDER BY id DESC");
$total = $db->num_rows($rt);
$data_photo_num = $total;
$nav='my';?>
<!doctype html><html><head><meta charset="utf-8">
<title><?php echo '我的相册';?></title>
<?php echo HEADMETA; ?>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/my_photo_video.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php
if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";?>
	<script src="<?php echo RES;?>jweixin-1.2.0.js"></script>
	<script>
	wx.config({debug: false,
		appId:'<?php echo $signPackage["appId"];?>',
		timestamp:<?php echo $signPackage["timestamp"];?>,
		nonceStr:'<?php echo $signPackage["nonceStr"];?>',
		signature:'<?php echo $signPackage["signature"];?>',
		jsApiList:['chooseImage','uploadImage','previewImage']
	});
	</script>
<?php }?>
<script>
var upMaxMB = <?php echo $_UP['upMaxMB']; ?>,browser='<?php echo browser();?>',up2='<?php echo $_ZEAI['up2'];?>/',GradeName = '<?php echo utitle($cook_grade); ?>';
</script>
<script src="<?php echo RES;?>m/js/ZeaiUP.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<style>
.tabmenu a.ed:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
header.bgcolor{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.nextbtn button{box-shadow:0 .3rem .8rem rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.4)}
.picli i.add{color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.6);border-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.2);background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
.picli i.add h5{color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.6)}
<?php
if ($_ZEAI['m_mb']==2){
	echo '.tabmenufix{width:70%;max-width:500px;top:1.5rem;margin:auto;left:0;right:0}';
	echo '#ZEAI_CN__FORM{padding-top:5rem}';
	$mini_class='top_mini4';
}else{
	echo '.tabmenufix{top:6.7rem}';
	echo '#ZEAI_CN__FORM{padding-top:10rem}';
	$mini_title='红娘牵线';
	$mini_class='top_mini4 zeaibg bgcolor yunbox';
}
?>
</style>
</head><body><?php
$mini_href = (!empty($jumpurl))?dataIO($jumpurl,'out'):'my.php';
$mini_href ='zeai.openurl(\''.$mini_href.'\');';
$mini_title='我的相册('.$data_photo_num .')';
require_once ZEAI.'m/top_mini.php';?>
<?php if(@in_array('video',$navarr)){?>
<div class="tabmenu tabmenu2 tabmenufix">
	<a href="my_photo.php" class="ed">个人相册</a>
	<a href="my_video.php">个人视频</a>
</div>
<?php }?>
<form id="ZEAI_CN__FORM">
<?php switch ($t){case 1:
/*********个人相册*********/?>
	<div class="picli" id="picli">
        <i class="add ico" id="btnadd">&#xe609;<h5>点击上传</h5></i>
        <?php
        if ($total > 0) {
			$pic_list = array();
            for($i=1;$i<=$total;$i++) {
                $rows = $db->fetch_array($rt);
                if(!$rows) break;
                $id     = $rows[0];
                $path_s = $rows[1];
                $flag   = $rows[2];
                $dst_s = UP.$path_s;
                $dst_b = smb($dst_s,'b');
				$pic_list[]= $dst_b;
				$flagstr   = ($flag == 0)?'<span>审核中</span>':'';
                $list_str  = '';
                $list_str .= '<i id="li'.$id.'">';
                $list_str .= '<img src="'.$dst_s.'">'.$flagstr.'<b class="ico">&#xe62c;</b>';
                $list_str .= '</i>';
                echo $list_str;
            }
			$pic_list = encode_json($pic_list);
        }
		$PcfgMaxnum = $photo_num->$cook_grade;?>
    </div>
    <div id="p_vipHelp" class="helpDiv">
        <ul><?php
        foreach ($urole as $uv) {
            $grade = $uv->g;
            $title = $uv->t;
			$ifmy = ($cook_grade==$grade)?'　　<font class="Cf00">（我）</font>':'';
            $out1 .= '<li>'.uicon_grade_all($grade,1,$cook_sex).' '.$title.' <i class="ico">&#xe62d;</i> <font class="Cf00">'.$photo_num->$grade.'</font> 张'.$ifmy.'</li>';
        }echo $out1;
        ?></ul>
        <a href="my_vip.php" class="btn size3 HUANG vipbtn"><i class="ico">&#xe6ab;</i> 立即升级</a>
    </div>
    <script>
	<?php if ($data_photo_num>0){?>var pic_list=<?php echo $pic_list;?>;<?php }
			$multiple=$PcfgMaxnum-$data_photo_num;
			$multiple=($multiple<=0)?0:$multiple;
	?>
	var data_photo_num=<?php echo $data_photo_num;?>,PcfgMaxnum=<?php echo $PcfgMaxnum;?>,maxnum=PcfgMaxnum,curnum=data_photo_num,multiple=<?php echo $multiple;?>;
	btnadd.onclick=function(){
		if ( data_photo_num >= PcfgMaxnum ){
			ZeaiM.div2({obj:p_vipHelp,title:'【'+GradeName+'】最多只能 '+PcfgMaxnum+' 张照片',w:30,h:32});	
		}else{
			ZeaiUP.multiple({
				onclick:false,
				btnadd:btnadd,
				url:"my_photo"+zeai.extname,
				submitokBef:"ajax_photo_",
				multiple:multiple,
				end:function(rs){
					location.reload(true);
				}
			});
		}
	}
	zeai.listEach(picli.getElementsByTagName("i"),function(obj){
		if (zeai.empty(obj.className)){
			var view=obj.getElementsByTagName("img")[0],del =obj.getElementsByTagName("b")[0];
			view.onclick=function(){photoView(this.src.replace('_s','_b'));	}
			del.onclick=function(){
				zeai.alertplus({'title':'确定要删除么？','content':'','title1':'取消','title2':'删除',
					'fn1':function(){zeai.alertplus(0);},
					'fn2':function(){zeai.alertplus(0);PVdel(obj.id.replace('li',''),'ajax_photo_del');}
				});
			}
		}
	});
    </script>
    <script src="<?php echo RES;?>m/js/my_photo_video.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php break;}?>
</form>
<?php
if($_ZEAI['m_mb']==2){
	require_once ZEAI.'m/bottom2.php';
}else{
	require_once ZEAI.'m/TRnav.php';
	require_once ZEAI.'m/bottom.php';
}
?>